package common;

import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import entity.Entity;

public class Constant {
	
	
	public static final int ENGLISH = 0;
	public static final int VIETNAMESE = 1;
	
	
	public static final float PIXELS_PER_METER = 60.0f;
	
    public static final int CatalogScreen = 0;
    public static final int ChooseModeScreen = 1;
    public static final int GameScreen = 2;
    public static final int HelpScreen = 3;
    public static final int LoadGameScreen = 4;
    public static final int LogInScreen = 5;
    public static final int MainMenuScreen = 6;
    public static final int OptionScreen = 7;
    public static final int ChooseLevelSceen= 8;
    public static final int SubmitScoreScreen = 9;
    
    public static final int MONEYINIT = 10000;
    
    public static final int CLASSICMODE = 0;
    public static final int NORMALMODE = 1;
    
	
	public static final int MOVE_UP = 0;
	public static final int MOVE_DOWN = 1;
	
	/*
	 * @Duochv
	 */
	// ENTITY ID
		
	public static final int SHIPBT = 0;
	public static final int SHIPDK = 1;
	public static final int SHIPDD = 2;
	public static final int SHIPDDK = 3;
	public static final int SHIPPK = 4;
	public static final int SHIPSB = 5;
	public static final int SHIPSUPPORT = 6;
	
	public static final int PLAYER = 7;
	public static final int FLAGVN = 8;
	public static final int MISSILE = 9;	
	public static final int BOMB = 10;
	public static final int CLUSTER = 11;
	public static final int ATOMIC = 12;
	public static final int TOMAHAWK = 13;
	public static final int EXPLOSION = 14;
	public static final int PLANESUPPORT = 15;
	public static final int PLANEFIGHTER = 16;
	
	public static final int AIRMISSILE = 17;
	public static final int BIGAIRMISSILE = 18;
	
	// STATE
	
	public static final int RUNNING = 0;
	public static final int ATTACK = 1;
	public static final int EXPLODE = 2;
	public static final int ESCAPE = 3;
	
	
	public static final int GO_LEFT = 0;
	public static final int GO_RIGHT = 1;
	
	public static final int SHIP_DROP = 0;
	public static final int PLANE_DROP = 1;
	
	public static final int ALLIED = 0;
	public static final int ENEMY = 1;
	
	public static final int MISSILES = 10;

	public static final int GACH = 0;
	public static final int XANG = 1;
	public static final int TANGHINH = 2;
	public static final int BOMCHUM =3;
	public static final int TENLUA =4;
	public static final int BOMNGUYENTU = 5;
	public static final int NGHIQUYET = 6;
	public static final int CHEAT = 7;
	public static final int LIFE = 8;
	
	
	/*
	 * @ChristHieu
	 */
//	
//	public static final int HEALTH_SHIPBT = 0;
//	public static final int HEALTH_SHIPDD = 1;
//	public static final int HEALTH_SHIP_DDK = 2;
//	public static final int HEALTH_SHIP_DK = 3;
//	public static final int HEALTH_SHIP_PK = 4;
//	public static final int HEALTH_SHIP_SB = 5;
//	public static final int HEALTH_SHIP_SUPPORT = 6;
	
	public static final double EPSILON = 0.01;
	
	// FILTERING
	public static final short CATEGORY_PLAYER = 0x0001;
	public static final short CATEGORY_SHIP_CHINA = 0x0002;
	public static final short CATEGORY_PLANE_FIGHTER = 0x0004;
	public static final short CATEGORY_SCENERY = 0x0008;
	public static final short CATEGORY_MISSILE = 0x0016;
	public static final short CATEGORY_PLANE_SUPPORT = 0x0032;
	public static final short CATEGORY_ITEM = 0x0064;
	public static final short CATEGORY_BULLET = 0x0128;

	//MASK
	public static final short MASK_PLAYER = CATEGORY_SCENERY | CATEGORY_MISSILE;
	public static final short MASK_CATEGORY_PLANE_SUPPORT = -1;
	public static final short MASK_CATEGORY_SHIP_CHINA = CATEGORY_SCENERY;
	public static final short MASK_CATEGORY_PLANE_FIGHTER = CATEGORY_PLAYER | CATEGORY_SCENERY;
	public static final short MASK_CATEGORY_MISSILE = CATEGORY_PLAYER;
	public static final short MASK_CATEGORY_SCENERY = -1;
	public static final short MASK_CATEGORY_ITEM = CATEGORY_PLAYER; 
	public static final short MASK_CATEGORY_BULLET = CATEGORY_SHIP_CHINA; 
		
	//CONSTANT 
	public static final Vector2 ZERO_VELOCITY = new Vector2(0.0f, 0.0f);
	public static final float STOP_WALLS = 4.5f;
	public static final float RADIUS_SHOOT_1 = 3.0f;
	public static final float RADIUS_SHOOT_2 = 4.0f;
	public static float SPEED = 0.75f;
	public static float DISAPPEAR = 0.4f;
	
	/*
	 * @DuocHV
	 */
	
	// FLAG VIETNAM
	public static final int FLAG_NORMAL = 0;	
	
	public static final int SCREEN_WIDTH = 1024;
	public static final float SCREEN_HEIGHT = 650;
	public static final float BULLET_DELAY = 2.0f;
	public static final float ATOMIC_DELAY = 5.0f;
	
	
	// APPOTA VIETNAM
	
	// enter your clientKey, clientSecret here (the two keys that you receive after register app)
	public static final String CLIENT_KEY = "e9b86d82bcd78799fdd0d95e7332d65405045b044";	
	public static final String CLIENT_SECRET = "4382fecbf44ad71ad6dd48fd8162346505045b044";
	
	
	/**
	 * Define endpoint APIs:
	 * topup APIs: allow user to purchase TYM 
	 * 
	 */
	public static final String SMS_ENDPOINT = "https://api.appota.com/payment/topup_sms";
	public static final String CHECK_TOPUP_ENDPOINT = "https://api.appota.com/payment/topup";
	public static final String CARD_ENDPOINT = "https://api.appota.com/payment/topup_card";
	public static final String PAYPAL_ENDPOINT = "https://api.appota.com/payment/topup_paypal";
	public static final String BANK_ENDPOINT = "https://api.appota.com/payment/topup_bank";
	
	
	/**
	 * Android preference to save AccessToken
	 */
	public static final String SPRATLY_DEFENSE_PREF = "spartly_defense_pref";
	public static final String SAVING_AMOUNT_BOMCHUM = "bomchum_amount";
	public static final String SAVING_AMOUNT_TENLUA = "tenlua_amount";
	public static final String SAVING_AMOUNT_BOMNGUYENTU = "bomnguyentu_amount";
	public static final String SAVING_AMOUNT_NGHIQUYET = "nghiquyet_amount";
	public static final String SAVING_AMOUNT_LIFE = "life_amount";
	public static final String SAVING_AMOUNT_CHEAT = "cheat_amount";
	public static final String SAVING_LEVEL = "level_game";
	public static final String SAVING_SCORE = "score_game";
	public static final String SAVING_PLAYER_NAME = "player_name";
	
	public static final String REFRESH_TOKEN_PREF = "refresh_token_pref";
	public static final String REFRESH_TOKEN_KEY = "refresh_token";
	public static final String ACCESS_TOKEN_KEY = "access_token";
	public static final String ACCESS_TIME = "access_time";
	public static final String ACCESS_TIME_COUNT = "acess_time_count";
	
	/**
	 * Define scope for your app
	 * See more at appota api documents
	 */
	public static final String USER_INFO_SCOPE = "user.info";
	public static final String USER_EMAIL_SCOPE = "user.email";
	public static final String USER_COMMENT_SCOPE = "user.comment";
	public static final String USER_CHARGE_SCOPE = "user.charge";
	public static final String USER_PAYMENT_SCOPE = "user.payment";
	public static final String INAPP_SCOPE = "inapp";
	
	/**
	 * In-app purchase endPoint:
	 * Directly purchase cash to your app
	 * 
	 */
	public static final String INAPP_SMS_ENDPOINT = "https://api.appota.com/payment/inapp_sms";
	public static final String INAPP_CARD_ENDPOINT = "https://api.appota.com/payment/inapp_card";
	public static final String INAPP_BANK_ENDPOINT = "https://api.appota.com/payment/inapp_bank";
	public static final String INAPP_PAYPAL_ENDPOINT = "https://api.appota.com/payment/inapp_paypal";
	public static final String CHECK_INAPP_ENDPOINT = "https://api.appota.com/payment/inapp";

	
	
	//
	
	public static boolean distancePlayer(Body body, Entity player){
		double dis = Math.sqrt((body.getPosition().x - player.getBody().getPosition().x)
				* (body.getPosition().x - player.getBody().getPosition().x)
				+ (body.getPosition().y - player.getBody().getPosition().y)
				* (body.getPosition().y - player.getBody().getPosition().y));
		if(dis <= Constant.RADIUS_SHOOT_1) 
			return true;
		return false;
	}

	public static boolean overlapRectangles(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2) { 
	    if(x1 < x2 + w2 && 
	       x1 + w1 > x2 && 
	       y1 < y2 + h2 && 
	       y1 + h1 > y2) 
	        return true;
	    else 
	    	return false;
	}
	
    public static boolean checkCollision(int x1, int y1, int x2, int y2,int x3, int y3) {
        if (x2 <= x1 && x1 <= x3 && y2 <= y1 && y1 <= y3) { 
            return true;
        }
        else return false;
    }
    
    public static boolean checkCollisionForPlayer(int x0, int x1, int y1, int x2, int y2,int x3, int y3){
    	
    	if ((x2 <= x1 && x1 <= x3 && y2 <= y1 && y1 <= y3) || ((x2 <= x0 && x0 <= x3 && y2 <= y1 && y1 <= y3))) { 
            return true;
        }
        else return false;
    }
    
    public static boolean checkCollisionCloud(int x1, int x2, int x3){
    	
    	if(x1 >= x2 && x1 <= x3){
    		return true;
    	}
    	else return false;
    }
    
    public static boolean checkBossCollision(int xB, int yB, int wB, int hB, int xF, int yF, int wF, int hF){
    	
    	if(xF < xB + wB && xF + wF > xB && yF < yB + hB && yF + hF > yB){
	    	return true;
	    }
    	
    	return false;
    }
    
    public static boolean checkCollision(int xB, int yB, int wB, int hB, int xF, int yF, int wF, int hF)
    {
    	
	    xB = xB - (wB/2);
	    yB = yB - (hB/2);
    	
	    if(xF < xB + wB && xF + wF > xB && yF < yB + hB && yF + hF > yB){
	    	return true;
	    }
    
    	return false;
    }
}